<!DOCTYPE html>
<html>
<head>
    <title>ads form</title>
    <#include "/header.html">
    <style>
        .layui-upload-img {
            max-height: 100px;
        }
    </style>
</head>
<body class="bg-white">
<div id="appMain">
    <form class="layui-form layuimini-form" action="" lay-filter="dataForm">
        <div class="layui-form-item">
            <label class="layui-form-label required">图片</label>
            <div class="layui-input-block">
                <input type="hidden" name="img" value="">
                <div class="layui-upload">
                    <button type="button" class="layui-btn layui-btn-sm layui-bg-black" id="uploadBtn">选择图片</button>
                    <div class="layui-upload-list">
                        <img class="layui-upload-img" id="uploadPreview" src="">
                        <p id="uploadText"></p>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-block">
                <input type="text" name="title" placeholder="输入标题" value="" class="layui-input" autocomplete="off">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">postExcerpt</label>
            <div class="layui-input-block">
                <input type="text" name="postExcerpt" placeholder="输入标题" value="" class="layui-input" autocomplete="off">
            </div>
        </div>
      	<div class="layui-form-item layui-form-text editor-item">
            <label class="layui-form-label">文章内容</label>
            <div class="layui-input-block" id="editor">
            <p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; font-size: 12px; font-family: 微软雅黑; border: 0px; list-style: none; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);"><span style="margin: 0px; padding: 0px; font-size: 18px; font-family: KaiTi_GB2312; border: 0px; list-style: none;">5月31日下午，河池市宜州区职业教育中心在实训楼501心理咨询室开展”5.25”心理健康文化节活动，河池市宜州区教育局德育师范股副股长、心理咨询师曾丽平参加活动并现场指导，曾丽平导师是整合性艺术心理治疗团体导师，青少年成长指导专家，广西家庭教育讲师团讲师，广西教育学会心理健康教育专业委员会常务理事。曾丽平导师指导了本次心理健康文化节活动，对整合性艺术心理治疗作了介绍。曾丽平心理咨询师针对中职教师在学生的教育、教学中出现的心理问题进行了常见心理问题分析及体验治疗。心理咨询师韦忠军组织教师进行了整合性艺术心理治疗体验活动。全校班主任和政教科领导参加了活动，并体验了整合性艺术心理治疗活动。学校成立了心理咨询俱乐部，对师生开放，在校园内利用师生微信、Q群、板报进行了宣传，由心理咨询师韦月姝、韦忠军、庞燕负责咨询工作。心理咨询俱乐部的开设为师生解开了情绪上的郁结，帮助学生正确认识自己，接纳自己，进而欣赏自己，并克服成长中的障碍，改变自己的不良意识和倾向，充分发挥个人潜能，迈向自我现实，保持在学习过程中的心理健康。</span></p> <p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; font-size: 12px; font-family: 微软雅黑; border: 0px; list-style: none; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);"><span style="margin: 0px; padding: 0px; font-size: 18px; font-family: 宋体; border: 0px; list-style: none;"><span style="margin: 0px; padding: 0px; font-size: 12px; border: 0px; list-style: none;"><br style="margin: 0px; padding: 0px; font-family: 微软雅黑; border: 0px; list-style: none;"></span></span></p> <p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; font-size: 12px; font-family: 微软雅黑; border: 0px; list-style: none; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);"><img src="portal/20210927/788abd25f4840e95c97554ccb65a5074.jpg" width="640" height="400" alt="201905312233258281.jpg" style="margin: 0px; padding: 0px; border: 0px; list-style: none; vertical-align: middle;" title="201905312233258281.jpg"></p> <p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; font-size: 12px; font-family: 微软雅黑; border: 0px; list-style: none; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-family: 微软雅黑; font-size: 18px; text-align: center; background-color: rgb(255, 255, 255);">河池市宜州区教育局德育师范股副股长、心理咨询师曾丽平作指导讲话</span></p> <p><img src="default/20210927/48526652cbaeced75de5a41e07d7b60f.jpg" style="" title="201905312234248430.jpg"></p> <p><img src="default/20210927/7af22ed9275d4cba11d15b42b11509f1.jpg" style="" title="201905312236161648.jpg"></p> <p><span style="font-family: 微软雅黑; font-size: 18px; text-align: center; background-color: rgb(255, 255, 255);">参加活动的部分老师在做心理疗愈体验</span></p> <p><img src="default/20210927/3ee17db05d0718ce9b88190418c96b2c.jpg" style="" title="201905312237522298.jpg"></p> <p><span style="font-family: 微软雅黑; font-size: 18px; text-align: center; background-color: rgb(255, 255, 255);">教师在体验整合性心理疗愈艺术</span></p> <p><img src="default/20210927/112682787f105d1c892329602c867fd3.jpg" style="" title="201905312239051911.jpg"></p> <p><span style="font-family: 微软雅黑; font-size: 18px; text-align: center; background-color: rgb(255, 255, 255);"></span><span style="font-family: 微软雅黑; font-size: 18px; text-align: center; background-color: rgb(255, 255, 255);">教师在体验整合性心理疗愈艺术</span><img src="default/20210927/5c1e975905e74663e4ee518078e2e024.jpg" style="" title="201905312241032521.jpg"></p> <p><span style="font-family: 微软雅黑; font-size: 18px; text-align: center; background-color: rgb(255, 255, 255);">阳光心态，幸福教师体验活动</span></p> <p><img src="default/20210927/5772938636c9d999c486274eb2deb70e.jpg" style="" title="201905312300051741.jpg"></p> <p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; font-size: 12px; font-family: 微软雅黑; border: 0px; list-style: none; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255); text-align: center;"><span style="margin: 0px; padding: 0px; font-size: 18px; border: 0px; list-style: none;">参加“5.25”心理健康文化节启动仪式部分教师</span></p> <p><br></p>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">类型</label>
            <div class="layui-input-block">
                <!-- <input type="radio" name="type" value="0" title="通知" checked> -->
                <input type="radio" name="type" value="1" title="轮播图" checked>
            </div>
        </div>
        <!-- <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="0" title="禁用">
                <input type="radio" name="status" value="1" title="启用" checked="">
            </div>
        </div> -->

        <div class="layui-form-item layui-hide">
            <div class="layui-input-block">
                <button type="button" class="layui-btn layui-btn-normal" id="commitBtn" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    layui.use(['form', 'dtree', 'upload', 'wangEditor'], function () {
        var form = layui.form,
            dtree = layui.dtree,
            upload = layui.upload,
            wangEditor = layui.wangEditor,
            $ = layui.$;

        var editor = new wangEditor('#editor');
        editor.customConfig.showFullScreen = true;
        editor.customConfig.uploadImgServer = serverUrl('oss/file/upload');
        editor.customConfig.uploadFileName = 'image';
        editor.customConfig.pasteFilterStyle = false;
        editor.customConfig.uploadImgMaxLength = 1;
        editor.customConfig.uploadImgHooks = {
            timeout: function (xhr, editor) {
                layer.msg('上传超时！')
            },
            // 如果服务器端返回的不是 {errno:0, data: [...]} 这种格式，可使用该配置
            customInsert: function (insertImg, result, editor) {
                console.log(result);
                if (result.code === 0) {
                    insertImg(result.url);
                } else {
                    layer.msg(result.msg);
                }
            }
        };
        editor.customConfig.customAlert = function (info) {
            layer.msg(info);
        };
        //var str ='<p>66</p><img alt="" src="http://localhost:8089/admin/comment/gettu?name=111111.jpg">';
        //var str ='<p style="text-align: center;"><span style="color: rgb(49, 49, 49); font-family: 微软雅黑, Arial, Helvetica, sans-serif, 宋体; font-size: 18px; font-weight: 700; text-align: center; background-color: rgb(255, 255, 255);">《歌海传情 缤纷职校》刘三姐歌谣文化传承创新基地活动剪影</span></p> <p style="text-align: center;"><span style="margin: 0px; padding: 0px; font-size: 24px; font-family: 微软雅黑; border: 0px; list-style: none; text-decoration: none;"><a href="https://v.youku.com/v_show/id_XNDM2MTkxMzAwOA==.html?spm=a2ha1.12675304.uerCenter.5!3~5~5!2~DL~DD~A&amp;firsttime=65.53" target="_blank" style="margin: 0px; padding: 0px; font-size: 12px; font-family: 微软雅黑; border: 0px; list-style: none; text-decoration: none; white-space: normal;">山歌在我校课堂</a></span></p>';
        //$("#editor").html(str);
        var _parent = parent;
        $.ajax({
            type: "POST",
            url: serverUrl('portalpost/info/' + _parent.formDataId),
            success: function (result) {
            	console.log(result.info.postTitle)
                if (result.code === 0) {
                    //form.val('dataForm', result.info);
                    /* dtree.dataInit("menuTree", result.info.parentId);
                    dtree.selectVal("menuTree"); */
                    //typeTplUpdate(result.info.type);
                    //$('#uploadPreview').attr('src', result.info.img); //url
                    //form.render();
                    //editor.create();
                }
                editor.create();
            	var str=result.info.postContent;
                $("#editor").html(str);
            }
        });
        //不同类型菜单显示
        var typeTplUpdate = function(type) {
            $(".layui-form-item").removeClass('layui-hide');
            if (type == 1) {
                $(".editor-item").addClass('layui-hide');
            }
        }
        form.on('radio(menuType)', function(data){
            typeTplUpdate(data.value);
        });

        var submitForm = function () {
            var params = form.val('dataForm');
            params['id'] = _parent.formDataId || null;
            //params['content'] = editor.txt.html();
            if (params['parentId'] == '') {
                params['parentId']= 0;
            }
            var method = _parent.formDataId > 0 ? 'update' : 'save';
            submitFormData('article/'+method, params, function (res) {
                _parent.table.reload();
                _parent.loadMenuData();
            });
        };

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#uploadBtn'
            ,url: serverUrl('oss/file/upload')
            ,auto: false
            ,choose: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#uploadPreview').attr('src', result); //base64
                });
            }
            ,done: function(res){
                if(res.code > 0){
                    return layer.msg('上传失败');
                }
                form.val('dataForm', {'img': res.url});
                submitForm();
            }
        });

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            /*var params = data.field;
            params['content'] = editor.txt.html();
            alert(JSON.stringify(params));
            return false;*/
            var img = $('#uploadPreview').attr('src');
            if (img.indexOf('data:') === 0) {
                uploadInst.upload();
                return false;
            }
            submitForm();
            return false;
        });

    });
</script>
</body>
</html>